package server.demo.repository;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;
import server.demo.entity.Carriage;

import java.util.List;
import java.util.Optional;

@Repository
public interface CarriageRepository extends JpaRepository<Carriage, Long> {
    List<Carriage> findByTrainIdOrderByCarriageNumber(Long trainId);
    Optional<Carriage> findByTrainIdAndCarriageNumber(Long trainId, Integer carriageNumber);
    boolean existsByTrainIdAndCarriageNumber(Long trainId, Integer carriageNumber);
}